home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2055 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.7 KB  |  48 lines

  1. Path: lasernet.com!jonathan_wooldridge
  2. Newsgroups: comp.lang.c++
  3. Message-ID: <60114202823$71C7@lasernet.com>
  4. X-Gateway: Act-Up 4.6  14 Jan 96 20:28:23  LaserNet, Serving Fido style systems
  5. Date: Sun, 14 Jan 96 19:59:49 LOC
  6. Organization: 1BBS ■ Imperial Beach CA ■ 619∙429∙6521/6123 ■ (52:1000/153)
  7. From: Jonathan Wooldridge <jonathan_wooldridge@lasernet.com>
  8. Subject: Borland C++ asm{labels}
  9.  
  10. Hey, here's a joystick routine I've been trying to get working,
  11.     but I keep getting an "Undefined label 'Again:'" error.
  12.     I'm using Borland C++ v3.1, and this is my first attempt at an
  13.     in-line assembler routine, so bear with me...
  14.  
  15. inline word Joystick::Position(int StickNum){
  16.     word mask = 0x1 << StickNumber; // 0-Ax, 1-Ay, 2-Bx, 3-By
  17.     asm{
  18.         CLI                  ;// turn off interrupts for timing loop
  19.  
  20.         MOV    BX, mask      ;
  21.         MOV    DX, GAMEPORT  ;// Defined as 0x201 in header
  22.         MOV    CX, 0         ;// prepare to loop 65,535 times
  23.         OUT    DX, AL        ;// send <anything>...
  24.       Again:                 ;// HERE'S ME LABEL
  25.         IN     AL, DX        ;// recieve
  26.         TEST   AL, AH        ;// compare In with mask
  27.         LOOPNE Again;        ;// Bail if bit changed, or CX down to 0
  28.  
  29.         MOV    AX, 0         ;// subtract CX from 0 to get count of iterations
  30.         SUB    AX, CX
  31.  
  32.         STI                  ;// restore interrupts
  33.     };
  34.     return(_AX);
  35. };
  36.  
  37. The line that has the label 'Again:' in it produces an "unrecognized command"
  38.     error, and the line 'LOOPNE Again;' produces "Undefined Label"
  39.  
  40. Any help would be greatly appreciated :)
  41.  
  42.                  -SpyroGyra
  43. ... "42? 7 and a half million years and all you can come up with is 42?!"
  44. ---
  45.  * TLX v4.00 *
  46.  
  47. ---
  48.